package com.xindz.hgq.main;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xindz.hgq.R;
import com.xindz.hgq.activity.DefaultActivity;
import com.xindz.hgq.activity.LoadSirActivity;
import com.xindz.hgq.activity.LoginActivity;
import com.xindz.hgq.activity.LongImageActivity;
import com.xindz.hgq.activity.MvpActivity;
import com.xindz.hgq.activity.ShowAllActivity;
import com.xindz.hgq.activity.TitleActivity;
import com.xindz.hgq.activity.TitleToolBarActivity;
import com.xindz.hgq.base.BaseFragment;
import com.xindz.hgq.base.options.BaseFragmentOptions;
import com.xindz.hgq.utils.login.LoginEvent;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * @name HGQBase
 * @class name：com.xindz.hgq.main.view
 * @describe describe
 * @anthor XINDZ
 * @time 2018/1/15 17:11
 * @change
 * @chang time
 * @class describe
 */
public class TwoFragment extends BaseFragment implements LoginEvent {
    @BindView(R.id.bt_home_two_default)
    Button btHomeTwoDefault;
    @BindView(R.id.bt_home_two_mvp)
    Button btHomeTwoMvp;
    @BindView(R.id.bt_home_two_loadsir)
    Button btHomeTwoLoadsir;
    @BindView(R.id.bt_home_two_title)
    Button btHomeTwoTitle;
    @BindView(R.id.bt_home_two_all)
    Button btHomeTwoAll;
    Unbinder unbinder;
    @BindView(R.id.bt_home_two_title_toolbar)
    Button btHomeTwoTitleToolbar;
    @BindView(R.id.bt_home_two_login)
    Button btHomeTwoLogin;

    @Override
    public BaseFragmentOptions setOption() {
        return null;
    }

    @Override
    public int onCreateFragmentLayoutId() {
        return R.layout.fragment_home_two;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.bt_home_two_default, R.id.bt_home_two_mvp, R.id.bt_home_two_loadsir, R.id.bt_home_two_title,
            R.id.bt_home_two_all, R.id.bt_home_two_title_toolbar, R.id.bt_home_two_login,R.id.bt_home_two_longimage})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_home_two_default:
                ActivityUtils.startActivity(DefaultActivity.class);
                break;
            case R.id.bt_home_two_mvp:
                ActivityUtils.startActivity(MvpActivity.class);
                break;
            case R.id.bt_home_two_loadsir:
                ActivityUtils.startActivity(LoadSirActivity.class);
                break;
            case R.id.bt_home_two_title:
                ActivityUtils.startActivity(TitleActivity.class);
                break;
            case R.id.bt_home_two_title_toolbar:
                ActivityUtils.startActivity(TitleToolBarActivity.class);
                break;
            case R.id.bt_home_two_all:
                ActivityUtils.startActivity(ShowAllActivity.class);
                break;
            case R.id.bt_home_two_login:
                Bundle bundle = new Bundle();
                bundle.putSerializable("LoginEvent", new LoginEvent() {
                    @Override
                    public void onLoginSuccess() {
                        ToastUtils.showShort("登录成功");
                    }

                    @Override
                    public void onLoginFail() {
                        ToastUtils.showShort("登录失败");
                    }
                });
                ActivityUtils.startActivity(bundle, LoginActivity.class);
                break;
            case R.id.bt_home_two_longimage:
                ActivityUtils.startActivity(LongImageActivity.class);
                break;
        }
    }


    @Override
    public void onLoginSuccess() {
        ToastUtils.showShort("登录成功");
    }

    @Override
    public void onLoginFail() {
        ToastUtils.showShort("登录失败");
    }
}
